<template>
  <div class="app-container">
    <el-row :gutter="40" class="panel-group">

      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col" v-if="merchantData && merchantData.accountData">
        <el-card>
          <div slot="header" class="clearfix">
            <span>账户信息:</span>
          </div>
          <div>
            <p>余额：<span :style="{ color: merchantData.accountData.totalAmount < 500 ? 'red' : 'green' }">
                {{ merchantData.accountData.totalAmount }} ￥
              </span></p>
            <p></p>
          </div>
        </el-card>
      </el-col>

      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col" v-if="merchantData && merchantData.infoData">
        <el-card>
          <div slot="header" class="clearfix">
            <span>机构信息:</span>
          </div>
          <div>
            <p>机构名称：{{ merchantData.infoData.infoName }}</p>
            <p>公司名称：{{ merchantData.infoData.companyName }}</p>
          </div>
        </el-card>
      </el-col>
    </el-row>


    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="merchantInfoList">
      <el-table-column label="账户名称" align="center" prop="accountName" />
      <!-- <el-table-column label="操作类型" align="center" prop="actionTypeName" /> -->
      <el-table-column label="操作类型" align="center" prop="actionTypeName">
        <template slot-scope="scope">
          <span :style="{ 'color': getTextColor(scope.row.actionTypeName) }">{{ scope.row.actionTypeName }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="修改金额" align="center" prop="changeAmount" /> -->
      <el-table-column label="修改金额" align="center" prop="changeAmount">
        <template slot-scope="scope">
          <span :style="{ 'color': scope.row.changeAmount < 0 ? 'red' : 'green' }">{{ scope.row.changeAmount }}</span>
        </template>
      </el-table-column>
      <el-table-column label="原金额" align="center" prop="originAmount" />
      <!-- <el-table-column label="现金额" align="center" prop="currentAmount" /> -->
      <el-table-column label="现金额" align="center" prop="currentAmount">
        <template slot-scope="scope">
          <span :style="{ color: scope.row.currentAmount < 500 ? 'red' : 'green' }">
            {{ scope.row.currentAmount }} ￥
          </span>
        </template>
      </el-table-column>
      <el-table-column label="账单日期" align="center" prop="billDateInfo" />
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>



<script>
import { listMerchantInfo, getMerchaneInfoData } from "@/api/merchantdata/merchatInfo";


export default {
  name: "MerchantInfoHis",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 商户账户流水表格数据
      merchantInfoList: [],
      merchantInfoList: [0],
      totalAmount: 0,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      // 查询参数
      queryParams: {
        dateInfo: null,
        pageNum: 1,
        pageSize: 10

      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
      , merchantData: {
      }
    };
  },
  created() {
    this.getList();
    this.getMerchaneInfo();
  },
  methods: {
    getTextColor(actionType) {
      return actionType === "消耗" || actionType === "退款" ? 'red' : 'green';
    },
    /** 查询商户账户流水列表 */
    getList() {
      this.loading = true;
      listMerchantInfo(this.queryParams).then(response => {
        this.merchantInfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    getMerchaneInfo() {
      getMerchaneInfoData().then(response => {
        this.merchantData = response.data;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        dateInfo: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },


  }
};
</script>


<style lang="scss" scoped>
.panel-group {
  margin-top: 18px;

  .card-panel-col {
    margin-bottom: 32px;
    width: 325px;
  }


}
</style>
